<tagLib name="lbase"/>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>微信公众平台管理系统</title>
        <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">
    <include file="Public:header" />
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="__PUBLIC__/js/html5.js"></script>
    <![endif]-->
    <style type="text/css">
        dl,dt,dd,ul,ol,li,			
        form,select,input,textarea,button,		
        table,caption,tr,th,td {
            margin:0;
            padding:0;
        }
        .main {
            background-color: #f6f6f6;
            color: #635c73;
        }
        .tab-content .tab-pane {
            display: none;
        }
        .tab-content .in {
            display: block;
        }
        /* 文章新增编辑页,权限授权页,分类编辑页 tab标签 */
        .tab-nav {
            border-bottom-color: #e0e0e0;
        }
        .tab-nav .current a,
        .tab-nav .current a:hover {
            border-color: #7b66ab #e0e0e0 #f6f6f6;
        }
        /* 访问授权页面 大类区块 */
        .checkmod {
            width: 95%;
            margin: 0 auto;
            border-color: #ebebeb;
        }
        .checkmod dt {
            border-bottom-color: #ebebeb;
            background-color: #ECECEC;
        }
        /* 授权编辑页 */
        .checkmod {
            margin-bottom: 20px;
            border: 1px solid #ebebeb;
        }
        .checkmod dt {
            padding-left: 10px;
            height: 30px;
            line-height: 30px;
            font-weight: bold;
            border-bottom: 1px solid #ebebeb;
            background-color: #ECECEC;
        }
        .checkmod dd {
            padding-left: 10px;
            line-height: 30px;
        }
        .checkmod dd .checkbox {
            margin: 0 10px 0 0;
        }
        .checkmod dd .divsion {
            margin-right: 20px;
        }
        .checkbox + .checkbox,
        .radio + .radio {
            margin-left: 15px;
        }
        .checkbox, .radio {
            display: inline-block;
            height: 20px;
            line-height: 20px;
        }
        .checkbox input,
        .radio input {
            margin-right: 5px;
            *margin-right: 1px;
            vertical-align: -1px;
        }
        .hd .checkbox{
            font-weight: bold;
        }
    </style>
</head>

<!--[if lt IE 7 ]> <body class="ie ie6"> <![endif]-->
<!--[if IE 7 ]> <body class="ie ie7 "> <![endif]-->
<!--[if IE 8 ]> <body class="ie ie8 "> <![endif]-->
<!--[if IE 9 ]> <body class="ie ie9 "> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> 
<body class="">
    <!--<![endif]-->

    <!--顶部菜单-->
<include file="Public:navbar" />

<!--左侧导航条-->
<include file="Public:nav" />

<!--右侧整体区域-->
<div class="content">
    <div class="container-fluid">
        <div class="row-fluid">
               <div class="row-fluid">
                   <!--右侧栏目区域start-->
                   <div class="block">
                           <a class="block-heading" data-toggle="collapse">[{$group_name}]权限组授权管理</a>
                           <div class="block-body collapse in">

                           <div class="container-fluid" style="margin-top: 10px;">
                               <!--右侧栏目内容区域start-->
                               <div class="row">
                                   <div class="span12">
                                           <div class="pull-left">
                                               <a class="btn btn-primary" href="{$pre_url}">返 回</a>
                                           </div>
                                       </div>
                                       <!--右侧字段区域start-->
                                       <div class="span12 main" style="margin-top:10px;">
                                           <div class="tab-content">
                                               <!-- 访问授权 -->
                                               <div class="tab-pane in">
                                                   <form class="form-horizontal" enctype="application/x-www-form-urlencoded" method="POST" class="form-horizontal auth-form">
                                                       <fieldset>
                                                           <div id="legend" class="">
                                                               <legend class=""></legend>
                                                           </div>
                                                           <volist name="tree_list" id="node" >
                                                               <dl class="checkmod">
                                                                   <dt class="hd">
                                                                   <label class="checkbox"><input class="auth_rules rules_all" type="checkbox" name="rules[]" value="<?php echo $node['id']; ?>"<php>if(in_array($node['id'],$group_auth)) echo ' checked="checked"';</php>>{$node.title}</label>
                                                                   </dt>
                                                                   <dd class="bd">
                                                                   <volist name="node['_child']" id="child" >
                                                                       <div class="rule_check">
                                                                           <div>
                                                                               <label class="checkbox" <notempty name="child['tip']">title='{$child.tip}'</notempty>>
                                                                                   <input class="auth_rules rules_row" type="checkbox" name="rules[]" value="<?php echo $child['id'] ?>"<php>if(in_array($child['id'],$group_auth)) echo ' checked="checked"';</php>/>{$child.title}</label>
                                                                           </div>
                                                                           <notempty name="child['_child']">
                                                                               <span class="divsion">&nbsp;</span>
                                                                               <span class="child_row">
                                                                                   <volist name="child['_child']" id="op">
                                                                                       <label class="checkbox" <notempty name="op['tip']">title='{$op.tip}'</notempty>>
                                                                                           <input class="auth_rules" type="checkbox" name="rules[]" value="<?php echo $op['id'] ?>"<php>if(in_array($op['id'],$group_auth)) echo ' checked="checked"';</php>/>{$op.title}</label>
                                                                                   </volist>
                                                                               </span>
                                                                           </notempty>
                                                                       </div>
                                                                   </volist>
                                                                   </dd>
                                                               </dl>
                                                           </volist>
                                                           <div id='pop'></div>

                                                           <div class="form-actions">
                                                               <input type="hidden" value="{$id}" name="id" />
                                                               <button type="button" class="btn btn-primary" id='save'>保 存</button>&nbsp;&nbsp;
                                                               <a class="btn" href="{$pre_url}">返 回</a>
                                                           </div>
                                                       </fieldset>
                                                   </form>
                                               </div>
                                           </div>
                                       </div>
                                       <!--右侧字段区域end-->
                                   </div>
                                   <!--右侧栏目内容区域end-->
                               </div>

                           </div>
                       </div>
                       <!--右侧栏目区域end-->
                   </div>
                   <footer>
                       <include file="Public:footer" />
                   </footer>
               </div>
           </div>
        </div>
        <script type="text/javascript">
            $(function() {
                var save_button = $('#save');
                save_button.click(function() {
                    ajax_action();
                });
                function ajax_action() {
                    var data = $('form').serialize();
                    save_button.attr('disabled', 'disabled');
                    $.ajax({
                        type: "POST",
                        url: app_url + "/" + module_name + "/update_authorize_manage",
                        data: data,
                        dataType: 'json',
                        cache: false,
                        success: function(data) {
                            success(data);
                        },
                        error: function() {
                            error();
                        }
                    });
                }

                $('#pop').ajaxStart(function() {
                    $('#pop').html('<div class="alert alert-info"><button type="button" class="close" data-dismiss="alert">×</button>数据请求中，请稍候...</div>')
                            .fadeIn("slow");
                });
                function success(data) {
                    switch (data.data) {
                        case 1:
                            $('#pop').html('<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button>授权组权限修改成功！</div>')
                                    .fadeIn("slow").fadeOut(5000);
                            save_button.removeAttr('disabled');
                            break;
                        default:
                            $('#pop').html('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button>授权组权限修改失败！</div>')
                                    .fadeIn("slow");
                    }
                }
                function error() {
                    $('#pop').html('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button>远程服务器请求失败！</div>')
                            .fadeIn("slow")
                            .fadeOut(5000);
                }
            });
        </script>
        <script type="text/javascript" charset="utf-8">
            +function($) {
                //全选节点
                $('.rules_all').on('change', function() {
                    $(this).closest('dl').find('dd').find('input').prop('checked', this.checked);
                });
                $('.rules_row').on('change', function() {
                    $(this).closest('.rule_check').find('.child_row').find('input').prop('checked', this.checked);
                });
            }(jQuery);
        </script>
    </body>
</html>


